-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #372 - Add Distribution for tasks #373
base: master
Are you sure you want to change the base?
Closes #372 - Add Distribution for tasks #373
Conversation
lib/kadai-core/src/main/java/io/kadai/spi/task/internal/TaskDistributionManager.java
Show resolved
Hide resolved
da4edc2
to
36d24f4
Compare
@@ -52,6 +56,16 @@ public static WorkbasketBuilder defaultTestWorkbasket() { | |||
.orgLevel1("company"); | |||
} | |||
|
|||
public static TaskBuilder defaultTask( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's talk about this
// Distribute tasks based on the provided parameters | ||
BulkOperationResults<String, KadaiException> result; | ||
|
||
if (destinationWorkbasketIds != null && distributionStrategyName != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can refactor this in a separate method, let's discuss :)
10ded54
to
8316c7e
Compare
|
||
if (taskDistributionProviderList.isEmpty()) { | ||
LOGGER.info( | ||
"No Custom TaskDistribution Provider found. Running wit DefaultTaskDistributionProvider"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"No Custom TaskDistribution Provider found. Running wit DefaultTaskDistributionProvider"); | |
"No Custom TaskDistribution Provider found. Running with DefaultTaskDistributionProvider"); |
* <li>{@code sourceWorkbasketId} ({@code String}): The ID of the source workbasket. Must be | ||
* set if {@code taskIds} is null. | ||
* <li>{@code taskIds} ({@code List<String>}): A list of task IDs to be distributed. Must be | ||
* set if {@code sourceWorkbasketId} is null. The other parameter must be null to ensure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this description still correct considering the sourceWorkasbasketId must now always be provided? Refers to complete description, e.g. line 1079,1112 as well etc.
@PostMapping(path = RestEndpoints.URL_DISTRIBUTE) | ||
@Transactional(rollbackFor = Exception.class) | ||
public ResponseEntity<BulkOperationResultsRepresentationModel> distributeTasks( | ||
@Valid @RequestBody DistributionTasksRepresentationModel distributionTasksRepresentationModel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the @Valid here? I don't see the Model expressing any constraints. Would it even work?
if (taskIds.isEmpty()) { | ||
return operationResults; | ||
} else { | ||
checkIfTasksInSameWorkbasket(taskIds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two checks will also be performed, if no taskIds are provided and retrieved via the sourceWorkbasket, but we don't need it in this case, right?
86a9be0
to
9a24ce9
Compare
lib/kadai-core/src/main/java/io/kadai/task/internal/TaskDistributor.java
Show resolved
Hide resolved
9a24ce9
to
77441b0
Compare
77441b0
to
1df144f
Compare
} else { | ||
LOGGER.info("No distribution strategy specified. Using default distribution."); | ||
newTaskDistribution = | ||
new DefaultTaskDistributionProvider() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you add the default provider to the list of provider? In that case you don't even need a if-then-else block?
* workbasket. | ||
* @param destinationWorkbasketIds A list of {@linkplain Workbasket#getId() Ids} of the | ||
* destination workbaskets where tasks will be distributed. | ||
* @param distributionStrategyName The name of the custom distribution strategy to be applied. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strategy name is always the full qualified class name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the class, the simple name is sufficient. I have adjusted and specified the description accordingly.
lib/kadai-core/src/main/java/io/kadai/task/api/TaskService.java
Outdated
Show resolved
Hide resolved
1df144f
to
e6d9315
Compare
lib/kadai-core-test/src/test/java/acceptance/task/distribute/DistributeTaskAccTest.java
Show resolved
Hide resolved
lib/kadai-core/src/main/java/io/kadai/spi/task/internal/DefaultTaskDistributionProvider.java
Outdated
Show resolved
Hide resolved
lib/kadai-core/src/main/java/io/kadai/spi/task/internal/DefaultTaskDistributionProvider.java
Outdated
Show resolved
Hide resolved
if (taskIds == null) { | ||
if (destinationWorkbasketIds != null && distributionStrategyName != null) { | ||
result = | ||
taskService.distribute( | ||
workbasketId, | ||
destinationWorkbasketIds, | ||
distributionStrategyName, | ||
additionalInformation); | ||
} else if (destinationWorkbasketIds != null) { | ||
result = taskService.distributeWithDestinations(workbasketId, destinationWorkbasketIds); | ||
} else if (distributionStrategyName != null) { | ||
result = | ||
taskService.distributeWithStrategy( | ||
workbasketId, distributionStrategyName, additionalInformation); | ||
} else { | ||
result = taskService.distribute(workbasketId); | ||
} | ||
} else { | ||
if (destinationWorkbasketIds != null && distributionStrategyName != null) { | ||
result = | ||
taskService.distribute( | ||
workbasketId, | ||
taskIds, | ||
destinationWorkbasketIds, | ||
distributionStrategyName, | ||
additionalInformation); | ||
} else if (destinationWorkbasketIds != null) { | ||
result = | ||
taskService.distributeWithDestinations(workbasketId, taskIds, destinationWorkbasketIds); | ||
} else if (distributionStrategyName != null) { | ||
result = | ||
taskService.distributeWithStrategy( | ||
workbasketId, taskIds, distributionStrategyName, additionalInformation); | ||
} else { | ||
result = taskService.distribute(workbasketId, taskIds); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to extract this in a private method and simplify the if else chain, so that all possibilities are more clearly expressed in code.
e6d9315
to
87ed38a
Compare
87ed38a
to
a7f9c9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sieht gut aus 🙂
Thanks for your PR! Please fill out the following list :)